/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ${USER}
 * Date: ${YEAR}-${MONTH}-${DAY}
 * Time: ${TIME}
 */
public class Main {
    class Solution {
        public void rotate(int[] nums, int k) {
            int length = nums.length;
            int times = k % length;
            if (times ==0) {
                return;
            }
            List<Integer> list = new ArrayList<>();
            for(int i = length - times; i < length; i++) {
                list.add(nums[i]);
                //newArr[i - (length - times)] = nums[i];
            }
            for(int i = 0; i < length - times; i++) {
                list.add(nums[i]);
                //newArr[i + times] = nums[i];
            }
            for(int i = 0; i<length; i++) {
                nums[i] = list.get(i);
            }
            //System.arraycopy(newArr, 0, nums, 0, length);

        }
    }